package com.wsh.crawler.repository;

import com.wsh.crawler.entity.News;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

import java.util.Date;

@Repository
public interface NewsRepository extends MongoRepository<News, String> {
    boolean existsByMd5Hash(String md5Hash);
//    List<News> findBySourceAndCrawlTimeAfter(String source, Date time);
//    List<News> findByCrawlTimeBetween(Date start, Date end);

    // 根据爬取时间查询并分页
    Page<News> findByCrawlTimeAfterOrderByCrawlTimeDesc(Date crawlTime, Pageable pageable);

    // 查询所有数据并分页
    Page<News> findAllByOrderByCrawlTimeDesc(Pageable pageable);

}
